﻿package com.PlantVsZombies.Plants;

import java.awt.Graphics;

import com.PlantVsZombies.common.Plant;
import com.PlantVsZombies.constant.PlantType;
import com.PlantVsZombies.util.ImageUtil;

public class SmallStonePlant extends Plant implements Runnable{

	boolean isAttacked = false;
	
	
	public boolean isAttacked() {
		return isAttacked;
	}
	public void setAttacked(boolean isAttacked) {
		this.isAttacked = isAttacked;
	}
	public SmallStonePlant(int x,int y){
		this.x = x;
		this.y = y;
		this.plantImage = ImageUtil.STONE;
		this.life = 10;
	}
	@Override
	public PlantType getType() {
		// TODO Auto-generated method stub
		return PlantType.SmallStone;
	}

	@Override
	public void drawMe(Graphics g, int x2, int y2) {
		// TODO Auto-generated method stub
		if(this.life>6)
			g.drawImage(plantImage.getImage(), x2, y2,null);
		else if(this.life>3)
			g.drawImage(ImageUtil.STONE1.getImage(), x2, y2, null);
		else
			g.drawImage(ImageUtil.STONE2.getImage(), x2, y2, null);
	}

	@Override
	public void shootBullet() {
		// TODO Auto-generated method stub
		
	}
	@Override
	public int doRun() {
		// TODO Auto-generated method stub
		if(isAttacked && life>0){
			life--;
		}
		//System.out.println(life);
		if(life == 0){
			this.setLive(false);
			this.isAttacked = false;
			return 0;
		}
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return 1;
	}

}
